var account_add = {
	init:function()
	{
		var $join_time = $("#join_time");
		if($join_time.length > 0){
			$join_time.datepicker();
		}
		
		var $form_submit = $('#form-submit');
		if($form_submit.length > 0){
			$form_submit.bind('click',function(){
				account_add.submitCheck();
			});
		}
					
	},
	submitCheck:function(){
	   var $password = $('#password');	
	   var $sure_password = $('#sure_password');
	   var pval = $password.val();
	   var spval = $sure_password.val();
	   if(pval && spval){
		   if(spval!=pval){
			    $('#repwd_err_text div:first').removeClass('form-ok').addClass('form-no').text('两次输入密码不一致');
				$(window).scrollTop($("#sure_password").position().top);
				return false;
		   }
	   }
	   
	   
	   if(!validate()){
         return false;
	   }
	   
	   var checkNum = 0;
	   var $checks = $("#permissions-check-box").find('.permissions-checkbox');
	   $checks.each(function(index, element) {
            if($(this).is(':checked')){
				checkNum+=1;
			}
       });
	
	   if(checkNum===0){
		   $('#permissions_err_text').html('<div class="form-no">请选择需要设置的账户权限！</div>');
		   return false;
	   }else{
		   $('#permissions_err_text').html('<div class="form-ok"></div>');
	   }
	   
	   
	  
	   
	   $('#form-box').submit();
	   
	}
}


$(function(){
    account_add.init();
});